//
//  BabyActivityEntry.m
//  BabyHelper
//
//  Created by  thomas on 11-2-11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "BabyActivityEntry.h"


@implementation BabyActivityEntry

@synthesize index,name, category, comments, timestamp, amount;

-(NSString*) getCategoryName {
	
	switch (self.category) {
		case EAT_MUM_CATEGORY:
			return NSLocalizedString(@"Mum",@"");
		case EAT_MILK_CATEGORY:
			return NSLocalizedString(@"Milk",@"");
		case DRINK_WATER_CATEGORY:
			return NSLocalizedString(@"Water",@"");
		case PEE_CATEGORY:
			return NSLocalizedString(@"Pee",@"");
		case SHIT_CATEGORY:
			return NSLocalizedString(@"Shit",@"");
		default:
			return @"";
	}
}

-(NSString*) getAmountDetails {
	
	if(self.amount > 0 ) 
	{
		switch (self.category) {
			case EAT_MUM_CATEGORY:
				return [NSString stringWithFormat:@"%dmin",self.amount];
			case EAT_MILK_CATEGORY:
			case DRINK_WATER_CATEGORY:
				return [NSString stringWithFormat:@"%dml",self.amount];
			case PEE_CATEGORY:
			case SHIT_CATEGORY:
			default:
				return @"";
		}
	}
	else
		return @"";
}

-(NSString*) getTimeStringWithOutYear {
	NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
	[dateFormatter setDateFormat:DATE_TIME_FORMAT_NO_YEAR];
	NSString *strTime = [dateFormatter stringFromDate:self.timestamp];			
	[dateFormatter release];
	return strTime;
}

-(NSString*) getTimeStringWithYear {
	NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
	[dateFormatter setDateFormat:DATE_TIME_FORMAT];
	NSString *strTime = [dateFormatter stringFromDate:self.timestamp];			
	[dateFormatter release];
	return strTime;
}

-(id) proxyForJson{
	return [NSDictionary dictionaryWithObjectsAndKeys:
						[NSNumber numberWithInt:index],@"index",
						[NSNumber numberWithInt:category],@"category",
						[NSNumber numberWithInt:amount],@"amount",
						comments,@"comments",
						name,@"name",
						[self getTimeStringWithYear],@"timestamp",
						nil];
}

@end
